package com.wdhcr.repository;


import com.wdhcr.entity.Comment;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;

import java.util.List;

public interface CommentRepository extends JpaRepository<Comment, Long> {
    //根据博客id查询本篇博客的评论列表
    @Query("select c from Comment c where c.pid = 0 and c.blog.id = ?1")
    List<Comment> findCommentsListById(Long id);


    //    @Query("select c.openid from Comment c where c.pid = ?1")
//    String findByPid(Long pid);

    @Query("select c.openid from Comment c where c.id = ?1")
    String findOpenidById(Long id);
}
